import java.awt.Container;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JPanel;


public class VistaPizarra extends JFrame{

	private static final long serialVersionUID = 1L;
	
	private JPanel panel;
	private List<Linea> lineas;

	public VistaPizarra(){
		lineas = new ArrayList<Linea>();
		Container c = this.getContentPane();
		panel = new JPanel() {
			private static final long serialVersionUID = 1L;

			@Override
			public void paint(java.awt.Graphics g) {
				for(Linea linea : lineas){
					g.setColor(linea.getColor());
					g.drawPolyline(linea.getPuntosX(), linea.getPuntosY(), linea.getCantidadPuntos());
				}
			};
		};
		panel.setPreferredSize(new Dimension(800, 480));
		c.add(panel);
		this.pack();
		this.setVisible(true);
	}
	
	public void nuevaLinea(Linea linea) {
		lineas.add(linea);
	}

	public Linea getUltimaLinea(int pointer) {
		Linea l = null;
		for(Linea linea : this.lineas){
			if(linea.getPointer() == pointer)
				l = linea;
		}
		return l;
	}
	
	public void removeLinea(Linea linea) {
		lineas.remove(linea);
	}

	public void borrar() {
		lineas = new ArrayList<Linea>();
		repaint();
	}

}
